package io.renren.modules.lucky.dao;

import io.renren.common.dao.BaseDao;
import io.renren.modules.lucky.entity.LuckyBillEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;

/**
 * 招财猫结算记录
 *
 * @author Liang Pei 
 * @since 1.0.0 2025-01-06
 */
@Mapper
public interface LuckyBillDao extends BaseDao<LuckyBillEntity> {
    // status为1:待确认账单（可结算）; 2-待上传发票（账单已确认）；3-待审核（确认发票
    //）； 4-审核失败 5-打款中（发票已确认），6-已打款（审核通过） 这里为待审核和打款中的金额
    @Select("SELECT SUM(amount) FROM lucky_bill WHERE plat_code = #{platCode} AND status IN (3, 5)")
    BigDecimal querySettlementAmount(String platCode);

    // status为6:已打款（审核通过） 这里为已打款金额
    @Select("SELECT SUM(amount) FROM lucky_bill WHERE plat_code = #{platCode} AND status = 6")
    BigDecimal queryPaidAmount(String platCode);
}